/**
 * 默认的路由
 */
import LogoutIcon from '@/assets/assets-slide-logout.svg';

const Layout = () => import('@/layouts/index.vue');

const routes = [
  {
    path: '/',
    redirect: '/dashboard/base',
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/pages/anonymous/login/index.vue'),
    meta: { anon: true },
  },
  {
    path: '/loginRedirect',
    name: 'loginRedirect',
    redirect: '/login',
    meta: { title: '登录页', icon: LogoutIcon, anon: true },
    component: () => import('@/layouts/blank.vue'),
    children: [
      {
        path: 'index',
        redirect: '/login',
        component: () => import('@/layouts/blank.vue'),
        meta: { title: '登录中心', anon: true },
      },
    ],
  },
  {
    path: '/result',
    name: 'result',
    component: Layout,
    redirect: '/result/success',
    meta: { title: '结果页', icon: 'check-circle', anon: true },
    children: [
      {
        path: 'success',
        name: 'ResultSuccess',
        component: () => import('@/pages/anonymous/result/success/index.vue'),
        meta: { title: '成功页', anon: true },
      },
      {
        path: 'fail',
        name: 'ResultFail',
        component: () => import('@/pages/anonymous/result/fail/index.vue'),
        meta: { title: '失败页', anon: true },
      },
      {
        path: 'network-error',
        name: 'ResultNetworkError',
        component: () => import('@/pages/anonymous/result/network-error/index.vue'),
        meta: { title: '网络异常', anon: true },
      },
      {
        path: '403',
        name: 'Result403',
        component: () => import('@/pages/anonymous/result/403/index.vue'),
        meta: { title: '无权限', anon: true },
      },
      {
        path: '404',
        name: 'Result404',
        component: () => import('@/pages/anonymous/result/404/index.vue'),
        meta: { title: '访问页面不存在页', anon: true },
      },
      {
        path: '500',
        name: 'Result500',
        component: () => import('@/pages/anonymous/result/500/index.vue'),
        meta: { title: '服务器出错页', anon: true },
      },
      {
        path: 'browser-incompatible',
        name: 'ResultBrowserIncompatible',
        component: () => import('@/pages/anonymous/result/browser-incompatible/index.vue'),
        meta: { title: '浏览器不兼容页', anon: true },
      },
      {
        path: 'maintenance',
        name: 'ResultMaintenance',
        component: () => import('@/pages/anonymous/result/maintenance/index.vue'),
        meta: { title: '系统维护页', anon: true },
      },
    ],
  },
  // 避免动态路由404问题，去掉这里的404通配，在动态路由增加404匹配
  // {
  //   path: '/:w+',
  //   name: '404Page',
  //   redirect: '/result/404',
  // },
];

if (import.meta.env.VITE_SSO_ENABLED_SERVER === 'true') {
  routes.push({
    path: '/sso',
    name: 'sso',
    redirect: '/sso/index',
    meta: { title: '登录页', icon: LogoutIcon, anon: true },
    component: () => import('@/layouts/blank.vue'),
    children: [
      {
        path: 'index',
        component: () => import('@/pages/anonymous/sso/index.vue'),
        meta: { title: '统一认证中心', anon: true },
      },
    ],
  });
}

export default routes;
